<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>3D螺旋轮播</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .slider{
            width: 600px;
            height: 300px;
            border: 1px solid red;
            margin: 150px auto;
            position: relative;
        }
        /*.slider-outer{*/
            /*transform-style: preserve-3d;*/
            /*transform: rotateY(30deg) rotateX(30deg);*/
        /*}*/

        .slider-outer,.slider-item,.img{
            width: 100%;
            height: 100%;
            position: absolute;
        }
        .slider-item{
            transform-style: preserve-3d;
            transition: all 2s;
        }
        .slider-item{
            width: 100px;
        }
        .img:nth-child(1){
            background-image: url("images/1-1.jpg");
            transform: rotateX(0deg) translateZ(150px);
        }
        .img:nth-child(2){
            background-image: url("images/1-2.jpg");
            transform: rotateX(90deg) translateZ(150px);
        }
        .img:nth-child(3){
            background-image: url("images/1-3.jpg");
            transform: rotateX(180deg) translateZ(150px);
        }
        .img:nth-child(4){
            background-image: url("images/1-4.jpg");
            transform: rotateX(270deg) translateZ(150px);
        }
        .btns{
            position: absolute;
            width: 100%;
            height: 50px;
            top: calc(50% - 25px);
        }
        .prev,.next{
            width: 50px;
            height: 50px;
            background-color: rgba(0,0,0,.3);
            position: absolute;
            color: #ffffff;
            font-size: 30px;
            text-align: center;
            line-height: 50px;
        }
        .prev{
            left: 0;
        }
        .next{
            right: 0;
        }
    </style>
</head>
<body>
<div class="slider">
    <div class="slider-outer">
        <div class="slider-item">
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
        </div>
        <div class="slider-item">
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
        </div>
        <div class="slider-item">
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
        </div>
        <div class="slider-item">
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
        </div>
        <div class="slider-item">
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
        </div>
        <div class="slider-item">
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
        </div>
    </div>
    <div class="btns">
        <div class="prev" id="prev">&lt;</div>
        <div class="next" id="next">&gt;</div>
    </div>
</div>
<script>
    var items=document.getElementsByClassName("slider-item");
    for(var i=0;i<items.length;i++){
        var item=items[i];
        var w=item.offsetWidth;
        item.style["left"]=w*i+"px";
        item.style["transitionDelay"]=.3*i+"s";
        var sub= item.children;
        for(var j =0;j<sub.length;j++){
            var img=sub[j];
            img.style["backgroundPosition"]=-w*i+"px";
        }
    }
    var num=0;
    document.getElementById("prev").addEventListener("click",function (e) {
        var rotate=90*++num;
        for(var i=0;i<items.length;i++){
             items[i].style["transform"]="rotateX("+rotate+"deg)";
            }
    });
    document.getElementById("next").addEventListener("click",function (e) {
        var rotate=90*--num;
        for(var i=0;i<items.length;i++){
            items[i].style["transform"]="rotateX("+rotate+"deg)";
        }
    })



</script>
</body>
</html>